﻿using System;
using System.Collections.Generic;
using System.Reflection;
using NUnit.Framework;

namespace Fabrication.Tests
{
    [TestFixture]
    public class conventions_provider
    {
        [Test]
        public void should_only_have_value_and_sealed_types_in_type_providers_collection()
        {
            var conventionsProvider = new ConventionsProvider();
            var field = typeof(ConventionsProvider).GetField("typeProviders", BindingFlags.NonPublic | BindingFlags.Instance);
            var dictionary = field.GetValue(conventionsProvider) as Dictionary<Type, Type>;
            foreach (var type in dictionary.Keys)
            {
                Assert.That(type.IsValueType || type.IsSealed, string.Format("Type '{0}' does not belong in the typeProviders collection as it is an unsealed reference type.", type));
            }
        }
    }
}